package com.zlx.store.domain.entity.vo;

import com.baomidou.mybatisplus.annotation.TableField;
import com.zlx.store.domain.entity.Order;
import com.zlx.store.domain.entity.OrderRelateGoods;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;
import java.util.List;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class OrderVO {
    /**
     * 订单id
     */
    @TableField("order_id")
    private Long orderId;
    /**
     * 订单的用户id
     */
    @TableField("order_user_id")
    private Long orderUserId;
    /**
     * 订单的地址
     */
    @TableField("order_address")
    private String orderAddress;
    /**
     * 订单总额
     */
    @TableField("order_amount")
    private Double orderAmount;
    /**
     * 订单的支付状态.1,新订单.2,发货中3,已完成.4,已取消
     */
    @TableField("order_state")
    private Integer orderState;
    /**
     * 订单创建时间
     */
    @TableField("order_create_time")
    private Date orderCreateTime;
    /**
     * 数据库订单中的商品
     */
    private List<OrderRelateGoods> orderRelateGoodsList;
    /**
     * 订购的商品订单
     */
    private List<GoodsVO> goodsVOList;
    /**
     * 建造者模式
     * @param orderRelateGoodsList
     * @param order
     * @return
     */
    public OrderVO build(List<OrderRelateGoods> orderRelateGoodsList, Order order) {
        this.orderRelateGoodsList = orderRelateGoodsList;
        this.orderId = order.getOrderId();
        this.orderState = order.getOrderState();
        this.orderAddress = order.getOrderAddress();
        this.orderAmount = order.getOrderAmount();
        this.orderUserId = order.getOrderUserId();
        return this;
    }

    ;
}
